package com.test.kotlin03

const val NAME = "Jimmy's friend"
const val NAMES = "jack,jacky,jason"


fun subStringTest(){
    var index = NAME.indexOf('\'');
//    val str = NAME.substring(0,index)
    val str = NAME.substring(0 until index)//range: IntRange 范围表示方法
    println(str)
}

fun splitTest(){
    var datas  =  NAMES.split(',')//解构语法特性
    val (origin,dest,proxy) = NAMES.split(',')
    println(" $origin $dest $proxy")
    println(datas)
}

fun replaceTest(){
    val str1 = "The people's Republic of China."
    val str2 = str1.replace(Regex("[aeiou]")){
        when(it.value){
            "a"->"8"
            "e"->"6"
            "i"->"9"
            "o"->"1"
            "u"->"3"
            else->it.value
        }
    }
    println(str1)
    println(str2)
}

fun equalTest(){
    val str1 = "Jason"
    val str2 = "jason".capitalize()

    println( str1 == str2)//比较内容
    println( str1 === str2)//比较对象
}


fun main(){

    subStringTest()
    splitTest()
    replaceTest()
    equalTest()

}
